package SocialMediaSentiment;

import java.io.IOException;
import java.util.HashMap;
import java.util.Iterator;
import java.util.StringTokenizer;

public class easyClassification {
	public static void main(String[] args) throws IOException {
		HashMap<Integer, String[]> wordsZeroNonZero = ReadExcel.read(
				"CorrectedCompareZeroNonZero.xls", 0, 1);
		HashMap<Integer, String[]> tweetsWithSentiment = ReadExcel.read(
				"CorrectedTweets.xls", 0, 1);
		Iterator<Integer> k = (Iterator<Integer>) tweetsWithSentiment.keySet()
				.iterator();
		int sentimentTweets = 0;
		int classifiedSentimentTweets = 0;
		while (k.hasNext()) {
			int index = k.next();
			String[] tweetSentiment = tweetsWithSentiment.get(index);
			if (Integer.parseInt(tweetSentiment[1].replace(" ", "")) != 0)
				sentimentTweets++;

			if (checkSentiment(tweetSentiment[0], wordsZeroNonZero)) {
				classifiedSentimentTweets++;
				//System.out.println(tweetSentiment[0]);
				//System.out.println(tweetSentiment[1]);
			}
		}
		System.out.println("Sentiment: " + sentimentTweets + " -- classified: " + classifiedSentimentTweets);
	}

	public static boolean checkSentiment(String tweet,
			HashMap<Integer, String[]> wordsZeroNonZero) {
		StringTokenizer tokenizer = new StringTokenizer(tweet);
		while (tokenizer.hasMoreTokens()) {
			String word = tokenizer.nextToken();
			Iterator<Integer> k = (Iterator<Integer>) wordsZeroNonZero.keySet()
					.iterator();
			while (k.hasNext()) {
				int index = k.next();
				String[] wordValue = wordsZeroNonZero.get(index);
				if (wordValue[0].equals(word)) {
					if (Double.parseDouble(wordValue[1]) == -1.0) {
						System.out.println(wordValue[0]);
						return true;
					}
					return false;
				}
			}
		}
		return false;
	}
}
